#include <iostream>
#include <iomanip>
void getcutflow(){
TFile *file = new TFile("test.root","read");
//TFile *file = new TFile("egamma_merge_00201138.root","read");
//TFile *file = new TFile("data12_201138.root","read");
//TFile *file = new TFile("test_simple.root","read");

TH1D *h1e = file->Get("cutflow_eg_num");
TH1D *h1m = file->Get("cutflow_mu_num");
TH1D *h1e_obj = file->Get("cutflow_eg_elec");
TH1D *h1e1_obj = file->Get("cutflow_eg_elec_1");
TH1D *h1m_obj = file->Get("cutflow_mu_muon");
TH1D *h1m1_obj = file->Get("cutflow_mu_muon_1");
TH1D *h1m1_calo_obj = file->Get("cutflow_mu_muon_2");
TH1D *h1j_obj = file->Get("cutflow_jet");
TH1D *h1j1_obj = file->Get("cutflow_jet_1");


cout<<"For electron stream"<<endl<<endl;

string cutflow_Ename[23] = {  "all","grl","hforRej","good vtx","met cleaning",
			   "LAr error","jet cleaning",">=1 loose lepton","1 signal lepton","trigger",
			   "lepton veto","met","mt","2 signal jets",">=1 bjet",
		 	   "2 bjet","jet veto","drjj>0.7","1 hight pt jet","wpt<50",
                           "wpt<100","wpt<200","wpt>200"};
 
for( int i=1; i<24; i++){
cout<<i<<"   "<<cutflow_Ename[i-1];
printf("%10d",h1e->GetBinContent(i));
cout<<endl;
}


cout<<"For muon stream"<<endl<<endl;
for( int i=1; i<24; i++){
cout<<i<<"   "<<cutflow_Ename[i-1];
if(i<9)printf("%10d",h1e->GetBinContent(i));
else printf("%10d",h1m->GetBinContent(i));
cout<<endl;
}

cout<<"For MC"<<endl<<endl;
for( int i=1; i<24; i++){
if(i<9){
cout<<i<<"   "<<cutflow_Ename[i-1];
printf("%10d",h1e->GetBinContent(i));
cout<<endl;
}
else{
cout<<i<<"   "<<cutflow_Ename[i-1];
printf("%10d",h1e->GetBinContent(i)+h1m->GetBinContent(i));
cout<<endl;
}
}



cout<<"For electron objet"<<endl<<endl;
string cutflow_EObjname[20] = { "all","author","tight","et","eta","d0",
			    "oq","sumpt","sumet","muonOver","jetOver",
			    "muon&jetOver","all cut","all cut+ jetOver","all cut+allOver","",
		            "  ","","",""}
for(int i=1; i<20;i++){
//cout<<i<<"   "<<cutflow_EObjname[i-1]<<"  "<<h1e_obj->GetBinContent(i)<<endl;
//printf("%10d",h1e_obj->GetBinContent(i));
cout<<i<<"   "<<cutflow_EObjname[i-1];
printf("%10d",h1e_obj->GetBinContent(i));
cout<<endl;
}

cout<<"For electron loose objet"<<endl<<endl;
string cutflow_lEObjname[20] = { "all","author","loose","et","eta","d0",
                            "oq","sumpt","sumet","muonOver","jetOver",
                            "muon&jetOver","all cut","all cut+ jetOver","all cut+allOver","allcut+d0",
                            "allcut+d0+overlap ","","",""}
for(int i=1; i<20;i++){
//cout<<i<<"   "<<cutflow_lEObjname[i-1]<<"  "<<h1e1_obj->GetBinContent(i)<<endl;
//printf("%10d",h1e1_obj->GetBinContent(i));
cout<<i<<"   "<<cutflow_lEObjname[i-1];
printf("%10d",h1e1_obj->GetBinContent(i));
cout<<endl;
}

cout<<"For muon objet"<<endl<<endl;
string cutflow_MObjname[20] = { "all","tight","blayer","pix","sct","pix sct hole",
                            "trtlo","trthi","z0","d0","pt",
                            "eta","sumpt","sumet","overlap","all cut",
                            "allcut+overlap","","",""}
for(int i=1; i<21;i++){
cout<<i<<"   "<<cutflow_MObjname[i-1];
printf("%10d",h1m_obj->GetBinContent(i));
cout<<endl;
}

cout<<"For muon loose objet"<<endl<<endl;
string cutflow_lMObjname[27] = { "all","medium","has track","blayer","pix",
				"sct","pix sct hole","trtlo","trthi","trt",
				"MCP hits","pt","eta","sumpt","overlap",
				"muid all cut","muid+overlap","standalone","standalone medium","standalone pt",
				"standalone eta","standalone all cut","standalone+overlap","muid/standalone","muid/standalone + overlap",
				"ZH signal","ZH signal + overlap"
				}
for(int i=1; i<28;i++){
cout<<i<<"   "<<cutflow_lMObjname[i-1];
printf("%10d",h1m1_obj->GetBinContent(i));
cout<<endl;
}

cout<<"For calo muon loose objet"<<endl<<endl;
string cutflow_calolMObjname[20] = { "all","author","blayer","pix","sct","pix sct hole",
                            "trt low","trt hi","trt","MCP hits","pt",
                            "eta","sumpt","quality","overlap","overlap with muid",
                            "calo muon all cut","calo muon all cut+overlap","",""}
for(int i=1; i<21;i++){
cout<<i<<"   "<<cutflow_calolMObjname[i-1];
printf("%10d",h1m1_calo_obj->GetBinContent(i));
cout<<endl;
}



cout<<"For  jet objet"<<endl<<endl;
string cutflow_JObjname[20] = { "all","e","","is_bad","","pt",
                            "eta","jvf","overlap","all cut","all cut+b",
                            "all cut + overlap","","","","",
                            "","","",""}
for(int i=1; i<20;i++){
cout<<i<<"   "<<cutflow_JObjname[i-1];
printf("%10d",h1j_obj->GetBinContent(i));
cout<<endl;
}

cout<<"For  jet loose objet"<<endl<<endl;
string cutflow_lJObjname[20] = {"all","e","","is_bad","","pt",
                            "eta","jvf","overlap","all cut","all cut+over",
                            "all cut + over","","","","",
                            "","","",""}
for(int i=1; i<20;i++){
//cout<<i<<"   "<<cutflow_lJObjname[i-1]<<"  "<<h1j1_obj->GetBinContent(i)<<endl;
//printf("%10d",h1j1_obj->GetBinContent(i));
//cout<<endl;
cout<<i<<"   "<<cutflow_lJObjname[i-1];
printf("%10d",h1j1_obj->GetBinContent(i));
cout<<endl;
}


}
